; Simple S_LBM_LISP_ARRAY vulnerability test
(print "Testing simple S_LBM_LISP_ARRAY vulnerability...")

; Create clearly insufficient data: claims 10 elements but only has 1 byte of data
(define malicious-data [
  0x1F          ; S_LBM_LISP_ARRAY type tag  
  0x00 0x00 0x00 0x0A  ; Claims 10 elements (big-endian)
  0xFF          ; Only 1 byte of data, nowhere near enough for 10 elements
])

; Try to unflatten
(define result (trap (unflatten malicious-data)))

(if (eq (car result) 'exit-ok)
    {
        (define created-result (car (cdr result)))
        ; Check if result is a safe value (symbol or nil)
        (if (or (eq created-result nil) (eq (type-of created-result) 'type-symbol))
            (print "SUCCESS - vulnerability fixed, returned safe value")
            (print "VULNERABILITY STILL EXISTS!"))
    }
    (print "SUCCESS - vulnerability fixed, unflatten failed"))